<?php
namespace App\Api\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Http\Exceptions\HttpResponseException;
abstract class Request extends FormRequest
{
    protected function failedValidation(Validator $validator)
    {
        $errormsg = $validator->errors()->messages();
        foreach ($errormsg  as $item) {
            $msg = current($item);
            break;
        };
        throw (new HttpResponseException(response()->json([
            'code' => 400,
            'success' => false,
            'message' => $msg,
        ], 400)));
    }
}
